package architecture.diagram.providers;

import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.emf.ecore.EAttribute;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.gmf.runtime.common.core.service.AbstractProvider;
import org.eclipse.gmf.runtime.common.core.service.IOperation;
import org.eclipse.gmf.runtime.common.ui.services.parser.GetParserOperation;
import org.eclipse.gmf.runtime.common.ui.services.parser.IParser;
import org.eclipse.gmf.runtime.common.ui.services.parser.IParserProvider;
import org.eclipse.gmf.runtime.common.ui.services.parser.ParserService;
import org.eclipse.gmf.runtime.emf.type.core.IElementType;
import org.eclipse.gmf.runtime.emf.ui.services.parser.ParserHintAdapter;
import org.eclipse.gmf.runtime.notation.View;

import architecture.ArchitecturePackage;
import architecture.diagram.edit.parts.FeatureDescriptionEditPart;
import architecture.diagram.edit.parts.FeatureNameEditPart;
import architecture.diagram.edit.parts.ModuleComplexityEditPart;
import architecture.diagram.edit.parts.ModuleDescriptionEditPart;
import architecture.diagram.edit.parts.ModuleNameEditPart;
import architecture.diagram.edit.parts.ResponsabilityDescription2EditPart;
import architecture.diagram.edit.parts.ResponsabilityDescriptionEditPart;
import architecture.diagram.edit.parts.ResponsabilityName2EditPart;
import architecture.diagram.edit.parts.ResponsabilityNameEditPart;
import architecture.diagram.parsers.MessageFormatParser;
import architecture.diagram.part.ArchitectureVisualIDRegistry;

/**
 * @generated
 */
public class ArchitectureParserProvider extends AbstractProvider implements
		IParserProvider {

	/**
	 * @generated
	 */
	private IParser moduleComplexity_5001Parser;

	/**
	 * @generated
	 */
	private IParser getModuleComplexity_5001Parser() {
		if (moduleComplexity_5001Parser == null) {
			EAttribute[] features = new EAttribute[] { ArchitecturePackage.eINSTANCE
					.getModule_Complexity() };
			MessageFormatParser parser = new MessageFormatParser(features);
			moduleComplexity_5001Parser = parser;
		}
		return moduleComplexity_5001Parser;
	}

	/**
	 * @generated
	 */
	private IParser moduleName_5002Parser;

	/**
	 * @generated
	 */
	private IParser getModuleName_5002Parser() {
		if (moduleName_5002Parser == null) {
			EAttribute[] features = new EAttribute[] { ArchitecturePackage.eINSTANCE
					.getModule_Name() };
			MessageFormatParser parser = new MessageFormatParser(features);
			moduleName_5002Parser = parser;
		}
		return moduleName_5002Parser;
	}

	/**
	 * @generated
	 */
	private IParser moduleDescription_5003Parser;

	/**
	 * @generated
	 */
	private IParser getModuleDescription_5003Parser() {
		if (moduleDescription_5003Parser == null) {
			EAttribute[] features = new EAttribute[] { ArchitecturePackage.eINSTANCE
					.getModule_Description() };
			MessageFormatParser parser = new MessageFormatParser(features);
			moduleDescription_5003Parser = parser;
		}
		return moduleDescription_5003Parser;
	}

	/**
	 * @generated
	 */
	private IParser responsabilityName_5004Parser;

	/**
	 * @generated
	 */
	private IParser getResponsabilityName_5004Parser() {
		if (responsabilityName_5004Parser == null) {
			EAttribute[] features = new EAttribute[] { ArchitecturePackage.eINSTANCE
					.getResponsability_Name() };
			MessageFormatParser parser = new MessageFormatParser(features);
			responsabilityName_5004Parser = parser;
		}
		return responsabilityName_5004Parser;
	}

	/**
	 * @generated
	 */
	private IParser responsabilityDescription_5005Parser;

	/**
	 * @generated
	 */
	private IParser getResponsabilityDescription_5005Parser() {
		if (responsabilityDescription_5005Parser == null) {
			EAttribute[] features = new EAttribute[] { ArchitecturePackage.eINSTANCE
					.getResponsability_Description() };
			MessageFormatParser parser = new MessageFormatParser(features);
			responsabilityDescription_5005Parser = parser;
		}
		return responsabilityDescription_5005Parser;
	}

	/**
	 * @generated
	 */
	private IParser featureDescription_5006Parser;

	/**
	 * @generated
	 */
	private IParser getFeatureDescription_5006Parser() {
		if (featureDescription_5006Parser == null) {
			EAttribute[] features = new EAttribute[] { ArchitecturePackage.eINSTANCE
					.getFeature_Description() };
			MessageFormatParser parser = new MessageFormatParser(features);
			featureDescription_5006Parser = parser;
		}
		return featureDescription_5006Parser;
	}

	/**
	 * @generated
	 */
	private IParser featureName_5007Parser;

	/**
	 * @generated
	 */
	private IParser getFeatureName_5007Parser() {
		if (featureName_5007Parser == null) {
			EAttribute[] features = new EAttribute[] { ArchitecturePackage.eINSTANCE
					.getFeature_Name() };
			MessageFormatParser parser = new MessageFormatParser(features);
			featureName_5007Parser = parser;
		}
		return featureName_5007Parser;
	}

	/**
	 * @generated
	 */
	private IParser responsabilityName_5008Parser;

	/**
	 * @generated
	 */
	private IParser getResponsabilityName_5008Parser() {
		if (responsabilityName_5008Parser == null) {
			EAttribute[] features = new EAttribute[] { ArchitecturePackage.eINSTANCE
					.getResponsability_Name() };
			MessageFormatParser parser = new MessageFormatParser(features);
			responsabilityName_5008Parser = parser;
		}
		return responsabilityName_5008Parser;
	}

	/**
	 * @generated
	 */
	private IParser responsabilityDescription_5009Parser;

	/**
	 * @generated
	 */
	private IParser getResponsabilityDescription_5009Parser() {
		if (responsabilityDescription_5009Parser == null) {
			EAttribute[] features = new EAttribute[] { ArchitecturePackage.eINSTANCE
					.getResponsability_Description() };
			MessageFormatParser parser = new MessageFormatParser(features);
			responsabilityDescription_5009Parser = parser;
		}
		return responsabilityDescription_5009Parser;
	}

	/**
	 * @generated
	 */
	protected IParser getParser(int visualID) {
		switch (visualID) {
		case ModuleComplexityEditPart.VISUAL_ID:
			return getModuleComplexity_5001Parser();
		case ModuleNameEditPart.VISUAL_ID:
			return getModuleName_5002Parser();
		case ModuleDescriptionEditPart.VISUAL_ID:
			return getModuleDescription_5003Parser();
		case ResponsabilityNameEditPart.VISUAL_ID:
			return getResponsabilityName_5004Parser();
		case ResponsabilityDescriptionEditPart.VISUAL_ID:
			return getResponsabilityDescription_5005Parser();
		case FeatureDescriptionEditPart.VISUAL_ID:
			return getFeatureDescription_5006Parser();
		case FeatureNameEditPart.VISUAL_ID:
			return getFeatureName_5007Parser();
		case ResponsabilityName2EditPart.VISUAL_ID:
			return getResponsabilityName_5008Parser();
		case ResponsabilityDescription2EditPart.VISUAL_ID:
			return getResponsabilityDescription_5009Parser();
		}
		return null;
	}

	/**
	 * Utility method that consults ParserService
	 * @generated
	 */
	public static IParser getParser(IElementType type, EObject object,
			String parserHint) {
		return ParserService.getInstance().getParser(
				new HintAdapter(type, object, parserHint));
	}

	/**
	 * @generated
	 */
	public IParser getParser(IAdaptable hint) {
		String vid = (String) hint.getAdapter(String.class);
		if (vid != null) {
			return getParser(ArchitectureVisualIDRegistry.getVisualID(vid));
		}
		View view = (View) hint.getAdapter(View.class);
		if (view != null) {
			return getParser(ArchitectureVisualIDRegistry.getVisualID(view));
		}
		return null;
	}

	/**
	 * @generated
	 */
	public boolean provides(IOperation operation) {
		if (operation instanceof GetParserOperation) {
			IAdaptable hint = ((GetParserOperation) operation).getHint();
			if (ArchitectureElementTypes.getElement(hint) == null) {
				return false;
			}
			return getParser(hint) != null;
		}
		return false;
	}

	/**
	 * @generated
	 */
	private static class HintAdapter extends ParserHintAdapter {

		/**
		 * @generated
		 */
		private final IElementType elementType;

		/**
		 * @generated
		 */
		public HintAdapter(IElementType type, EObject object, String parserHint) {
			super(object, parserHint);
			assert type != null;
			elementType = type;
		}

		/**
		 * @generated
		 */
		public Object getAdapter(Class adapter) {
			if (IElementType.class.equals(adapter)) {
				return elementType;
			}
			return super.getAdapter(adapter);
		}
	}

}
